<template>
  <div>
    <el-form ref="form" :rules="rules" :model="aduit">
      <el-form-item label="" prop="chkState">
      <el-radio-group v-model="aduit.chkState">
        <el-radio :label="1">通过</el-radio>
        <el-radio :label="2">拒绝</el-radio>
      </el-radio-group>
      </el-form-item>
      <el-form-item label="" class="aduitTop" prop="chkRemarks">
        <el-input
          v-model="aduit.chkRemarks"
          type="textarea"
          placeholder="请输入审核意见"
        >
        </el-input>
      </el-form-item>
      <el-form-item>
        <span class="footerRight">
          <el-button @click="cancel">取 消</el-button>
          <el-button type="primary" @click="aduitT">确 定</el-button>
        </span>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'aduit',
  props: {
    aduitId: {
      type: Number,
      required: true
    }
  },
  data () {
    return {
      aduit: {
        id: this.aduitId,
        chkState: 0, // 单选
        chkRemarks: '' // 意见
      },
      rules: {
        chkState: [{ required: true, message: '请选择', trigger: 'blur' }],
        chkRemarks: [{ required: true, message: '请输入数据', trigger: 'blur' }]
      }
    }
  },

  methods: {
    // 提交数据 点击确定
    async aduitT () {
      const res = await choiceCheck(this.aduit)
      console.log(res)
      this.$message.success('审批数据成功')
      this.cancel()
    },
    // 点击取消
    cancel () {
      this.aduit = {
        id: 0,
        chkState: 0,
        chkRemarks: ''
      }
      this.$refs.form.resetFields()
      this.$emit('cancel')
    }
  }
}
</script>

<style>
.radioLeft {
  float: left;
}
.aduitTop {
  margin-top: 20px;
}
.footerRight {
  margin-top: 30px;
  margin-bottom: -20px;
  float: right;
}
</style>
